SoSe2021
→ Warum nicht jede Tiefe mit der Kontrolle mittels t-Test vergleichen?
p.adjust() wandelt unkorrigierte p-Werte in korrigierte mittels Bonferroni-, Bonferroni-Holm- und weiteren Korrekturen um.\[H=\frac{12}{N*(N+1)}*\left( \sum\frac{R_i^2}{n_i} \right)-3*(N+1)\]
N = Gesamter Stichprobenumfang, \(n_i\) = Anzahl Messung pro Gruppe \(i\), \(R_i\) = Summe der Ränge pro Gruppe \(i\)
\[F_r=\left( \frac{12}{n*k*(k+1)}*\left( \sum R_i^2\right)\right)-3*n*(k+1)\]
n = Anzahl der Blöcke, k = Anzahl der Gruppen, \(R_i\) = Summe der Ränge pro Gruppe \(i\)
irisdf <- iris %>% mutate(ranks_sl = rank(Sepal.Length, ties.method = "average")) %>% group_by(Species) %>% summarise(sum_ranks = sum(ranks_sl)) df
# A tibble: 3 x 2 Species sum_ranks <fct> <dbl> 1 setosa 1482 2 versicolor 4132. 3 virginica 5710.
(h_sl <- 12/(150*(150+1))*sum(df$sum_ranks^2/50) - 3*(150+1))
[1] 96.76096
pchisq(h_sl, df = 3-1, lower.tail = FALSE)
[1] 9.741475e-22
kruskal.test() iris# x = abhängige Variable, g = Gruppierungsvariable/Faktor kruskal.test(x = iris$Sepal.Length, g = iris$Species)
# kruskal.test(x ~ g, data) kruskal.test(Sepal.Length ~ Species, data = iris)
Kruskal-Wallis rank sum test
data: Sepal.Length by Species
Kruskal-Wallis chi-squared = 96.937, df = 2, p-value < 2.2e-16friedman.test()friedman.test(y, groups, blocks) # y = abhängige Variable # groups = Messwiederholung -> eigentlich zu untersuchender Faktor # blocks = zu untersuchende Objekte # oder Formelsyntax friedman.test(y ~ groups|blocks, data)
irisEs soll die Hypothese getestet werden, dass sich die durchschnittliche Kronblattweite der drei Iris Arten unterscheidet.
kruskal.test(Petal.Width ~ Species, data = iris)
Kruskal-Wallis rank sum test
data: Petal.Width by Species
Kruskal-Wallis chi-squared = 131.19, df = 2, p-value < 2.2e-16factor definiert werden!Gewichtsunterschiede von Atlantischem Lachs, der in 4 verschiedenen Typen von Netzkäfigen gezüchtet wurde.
| Replikat | Typ A | Typ B | Typ C | Typ D |
|---|---|---|---|---|
| 1 | 2.0 | 2.7 | 2.9 | 2.2 |
| 2 | 2.7 | 2.0 | 1.9 | 2.0 |
| 3 | 2.2 | 3.8 | 2.7 | 3.1 |
| … | … | … | … | … |
| 24 | 3.1 | 1.5 | 2.5 | 2.7 |
| Mittelwert | 2.5 | 2.5 | 2.5 | 2.5 |
Gesamtmittelwert: 2.5
| Replikat | Typ A | Typ B | Typ C | Typ D |
|---|---|---|---|---|
| 1 | 5.0 | 4.1 | 2.9 | 0.8 |
| 2 | 5.0 | 4.1 | 2.9 | 0.8 |
| 3 | 5.0 | 4.1 | 2.9 | 0.8 |
| … | … | … | … | … |
| 24 | 5.0 | 4.1 | 2.9 | 0.8 |
| Mittelwert | 5.0 | 4.1 | 2.9 | 0.8 |
Gesamtmittelwert: 2.5
| Sources of variation | SS | df | MS | F | p |
|---|---|---|---|---|---|
| Groups | \(n \sum(\bar{y_i}-\bar{y})^2\) | \(p-1\) | \(\frac{SS_{Groups}}{(p-1)}\) | \(\frac{MS_{Groups}}{MS_{Residuals}}\) | |
| Residuals (or within) | \(\sum\sum(y_{ij}-\bar{y_i})^2\) | \(p(n-1)\) | \(\frac{SS_{Groups}}{(p-1)}\) | ||
| Groups | \(n \sum(y_{ij}-\bar{y})^2\) | \(pn-1\) |
H0:
Sowohl \(MS_{Groups}\) als auch \(MS_{Residuals}\) schätzen \(\sigma^2\) → Quotient = 1
| Sources of variation | SS | df | MS | F | p |
|---|---|---|---|---|---|
| Groups | 52.10 | 4-1 | 171724 | 17.367 | <2e-16 |
| Residuals (or within) | 26.02 | 4*(24-1) | 0.283 | ||
| Groups | 78.12 | 4*24-1 |
aov()aov(formula, data = NULL, projections = FALSE, qr = TRUE, contrasts = NULL, ...)
Die volle ANOVA Tabelle erhältst Du aber nur mit der summary() Funktion, die auf das aov Objekt angewendet wird:
model <- aov(formula, data) summary(model)
mod <- aov(formula = weight ~ cages, data = salmon) mod
Call:
aov(formula = weight ~ cages, data = salmon)
Terms:
cages Residuals
Sum of Squares 53.91378 18.51342
Deg. of Freedom 3 92
Residual standard error: 0.4485898
Estimated effects may be unbalanced
summary(mod)
Df Sum Sq Mean Sq F value Pr(>F)
cages 3 53.91 17.971 89.31 <2e-16 ***
[ erreichte getOption("max.print") -- Zeile 1 ausgelassen ]
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1op <- par(mfrow = c(2,2)) plot(mod)
par(op)
plot.design()Die Berechnung der Effektgröße für Designs zwischen Gruppen ist viel einfacher als für Designs innerhalb von Gruppen:
\[\eta^2 = \frac{SS_{Groups}}{SS_{Total}}\]
mod_sum <- summary(mod) # str(mod_sum) eta_sq <- mod_sum[[1]]$`Sum Sq`[1] / (mod_sum[[1]]$`Sum Sq`[1] + mod_sum[[1]]$`Sum Sq`[2] ) eta_sq
[1] 0.7443858
plot.design()plot.design(weight ~ cages, data = salmon)
Bei weiteren Fragen: saskia.otto(at)uni-hamburg.de

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License except for the borrowed and mentioned with proper source: statements.
Image on title and end slide: Section of an infrared satellite image showing the Larsen C ice shelf on the Antarctic Peninsula - USGS/NASA Landsat: A Crack of Light in the Polar Dark, Landsat 8 - TIRS, June 17, 2017 (under CC0 license)